#ifndef QUALITY_EVALUATION_HPP
#define QUALITY_EVALUATION_HPP

#include <iostream>
#include <opencv2/opencv.hpp>

struct imageInfo {
    std::string img_path;
    std::string img_id;
    double score;
};

namespace qe
{
    enum QualityEvaluationType
    {
        // Brenner梯度
        BRENNER,
        // Tenengrad梯度
        TENENGARD,
        // Laplacian梯度
        LAPLACIAN,
        // SMD灰度方差
        SMD,
        // SMD2灰度方差乘积
        SMD2,
        // ENERGY_GRADIENT灰度能量
        ENERGY_GRADIENT,
        // EAV点锐度
        EAV,
        // NRSS梯度结构相似度
        NRSS,
        // 模糊和噪声IQA
        BLUR_NOISE_IQA
    };

    // 获取图像质量评分
    double getQuality(cv::Mat &image, QualityEvaluationType type);
    // 裁切图像
    void cropImage(cv::Mat &inputs, cv::Mat &outputs, const float& rate);

    void write_to_txt(std::vector<imageInfo> &img_info, const std::string &path);
}

class calculate_time {
public:
    calculate_time(std::string name) : name_(name) {
        start_ = std::chrono::system_clock::now();
    }
    ~calculate_time(){}
    void print_time() {
        auto end = std::chrono::system_clock::now();
        auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start_);
        std::cout << name_ << "'s time: " << duration.count() << "ms" << std::endl;
    }

private:
    std::string name_;
    std::chrono::time_point<std::chrono::system_clock> start_;
};

#endif